package com.softeem.regex;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReadFile {

	public static String read(File file){
		StringBuffer sb = new StringBuffer();
		BufferedReader br =  null;
		try {
			FileInputStream fis = new FileInputStream(file);
			br = new BufferedReader(new InputStreamReader(fis));
			String str = "";
			while((str = br.readLine()) != null){
				sb.append(str).append("\n");
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return  sb.toString();
	}
	
	public static void main(String[] args) {
		String content = read(new File("src\\com\\softeem\\regex\\PhoneNumDemo.java"));
		System.out.println(content);
	}
}
